#include<iostream>
#include<string>
#include<set>
using namespace std;

void solve()
{
    string s;
    cin >> s;
    set<char>ss;
    for (int i = 0; i < s.size(); i++)
    {
        ss.insert(s[i]);
    }

    if (ss.size() == 1)
        cout << s.size() - 1 << "\n";
    else
        cout << "0\n";
    return;
}
signed main()
{
    solve();
    return 0;
}